package chpt05.shopping;

import chpt05.shopping.ui.ConsoleMenuImpl;
import chpt05.shopping.ui.GUIMenuImpl;
import chpt05.shopping.ui.IMenu;

public class Main {
	public static void main(String[] args) {
		// 初始化商品
		Commodity x1 = new Commodity(1, "iphone", 3000.0, "苹果手机");
		Commodity x2 = new Commodity(1, "iphone", 5000.5, "iphone");
		Commodity x3 = new Commodity(2, "book", 99.5, "Java程序设计");
		Commodity x4 = new Commodity(3, "TV", 6500.0, "65寸大彩电");

		IMenu menu = new ConsoleMenuImpl(); // 控制台界面版本
		// IMenu menu = new GUIMenuImpl(); // 图形用户界面版本

		/* 添加 */
		ShoppingCart cart = new ShoppingCart(10);
		cart.add(x1);
		cart.add(x2);
		cart.add(x3);
		cart.add(x4);
		menu.showShoppingCart(cart);
		/* 移除商品：数量减少 */
		cart.remove(x1.getId());
		menu.showShoppingCart(cart);
		/* 移除商品：移除一个条目 */
		cart.remove(x1.getId());
		menu.showShoppingCart(cart);
	}
}
